﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;


namespace WebApplication91
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

       
        protected void Buttonchekexistance_Click(object sender, EventArgs e)
        {
            string strcon = @"Data Source=.\sqlexpress;Initial Catalog=HMS;Integrated Security=True";
            SqlConnection con = new SqlConnection(strcon);

            SqlCommand com = new SqlCommand("existance", con);
            com.CommandType = CommandType.StoredProcedure;      
            SqlParameter p1 = new SqlParameter("email", TextBoxemail.Text);           
            com.Parameters.Add(p1);
            con.Open();
            SqlDataReader rd = com.ExecuteReader();
            if (rd.HasRows)
            {
               rd.Read();
                this.Labelinfo.ForeColor = System.Drawing.Color.Red;
                this.Labelinfo.Text = "already Exist!";
            }

            else
            {
                this.Labelinfo.Text = "you can login now";
                this.TextBoxusername.Text = "";
               this.TextBoxpassword.Text = "";
                this.TextBoxemail.Text = "";               
            } 

        }
    }
}